const app = getApp();
import grace from "../../../utils/grace.js";

grace.page({
    /**
     * 页面的初始数据
     */
    data: {
        rooms: []
    },
    onShow() {
        this.getList();
    },
    getList() {
        let that = this;

        wx.showLoading({
            title: '加载中...',
        })
        let url = app.globalData.api + '/api/v1.0/live/room/' + wx.getStorageSync('school_id');
        that.$http.get(url, {token: wx.getStorageSync('token')}).then((res) => {
            if (res.data.code == 0) {
                that.$data.rooms = res.data.data;
            } else if (res.data.code == 10001) {
                wx.navigateTo({
                    url: "/pages/common/authorize/index"
                })
            } else {
                that.$data.rooms = [];
            }
          wx.hideLoading();
        }).catch(err => {
            console.log(err.status, err.message);
        });
    }
})